#ifndef INTERFACE_WIN_HPP
#define INTERFACE_WIN_HPP

#include "GlobalDefines.hpp"
#include "Widget.hpp"
#include "View.hpp"

namespace mi
{
  class Win : public Widget
  {
  public:
    
    Win (std::string title, bool isMovable = true);

    bool Movable();

    bool Movable(bool isMovable);

    bool Contains(Widget *other);

    Widget* MouseClick(sf::Mouse::Button button, sf::MouseState state, int x, int y);
    
    Widget* MouseMoved(int x, int y, int dx, int dy);
    
    Widget* MouseDragged(int x, int y, int dx, int dy);
    
    Widget* MouseWheel(int dir);
    
    Widget* KeysDown(sf::Event::KeyEvent key);
    
    Widget* KeysUp(sf::Event::KeyEvent key);

    Widget* TextEntered(char ch);

    View& GetMainView ();

    View& AddHorizontalView (int weight = 1);

    View& AddVerticalView (int weight = 1);

    void Draw2D();

    bool Update(double dTime);

  protected:

    bool move;

    bool movable;

    bool resize;

    Vec2i minSize;

    int titlebarHeight;

    int resizeAreaSize;

    View mainView;

    bool IsMouseInTitlebar(int x, int y);

    bool IsMouseInResizeArea(int x, int y);

    void OnPositionChange(Vec2i oldPosition);

    void OnSizeChange(Vec2i oldSize);

    sf::Text title;

    sf::Text body;

    static sf::Texture *resizeTexture;
    
  };
}

#endif